package com.glorysoft.sunnypda.model

import com.glorysoft.sunnypda.base.BaseRepository
import com.glorysoft.sunnypda.base.Constant
import com.glorysoft.sunnypda.entity.*
import com.google.gson.JsonObject
import rxhttp.retry
import rxhttp.wrapper.param.RxHttp
import rxhttp.wrapper.param.toResponse

/**
 * FileName: EqpRepository
 * Author: XJH
 * Date: 2022/3/14 17:25
 * Description:
 * History:
 */
class EqpRepository : BaseRepository() {


    suspend fun getEqpInfo(map: JsonObject): EqpInfoEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/VIEW_PDA_EQP_INFO")
            .addAll(getInJsonData(map,"VIEW_PDA_EQP_INFO"))
            .toResponse<EqpInfoEntity>()
            .await()

    }

    suspend fun getEqpInfoMovein(map: JsonObject): EqpInfoEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/VIEW_PDA_EQP_INFO_BY_MOVEIN")
            .addAll(getInJsonData(map,"VIEW_PDA_EQP_INFO_BY_MOVEIN"))
            .toResponse<EqpInfoEntity>()
            .await()

    }

    suspend fun getEqpInfoMoveOut(map: JsonObject): EqpInfoEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/VIEW_PDA_EQP_INFO_BY_MOVEOUT")
            .addAll(getInJsonData(map,"VIEW_PDA_EQP_INFO_BY_MOVEOUT"))
            .toResponse<EqpInfoEntity>()
            .await()

    }

    suspend fun isFabLinePosition(map: JsonObject): Any {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/VIEW_PDA_EQP_INFO_BY_MOVEINBODY")
            .addAll(getInJsonData(map,"VIEW_PDA_EQP_INFO_BY_MOVEINBODY"))
            .toResponse<Any>()
            .await()

    }

    suspend fun getEqpInfoAdd(map: JsonObject): EqpInfoEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/VIEW_PDA_EQP_INFO_BY_ADD")
            .addAll(getInJsonData(map,"VIEW_PDA_EQP_INFO_BY_ADD"))
            .toResponse<EqpInfoEntity>()
            .await()

    }

    suspend fun getEqpUnLock(map: JsonObject): JsonObject {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/TRAN_PDA_EQP_UNLOCK")
            .addAll(getInJsonData(map,"TRAN_PDA_EQP_UNLOCK"))
            .toResponse<JsonObject>()
            .await()

    }


    suspend fun getAreaList(map: JsonObject): AreaListEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/VIEW_PDA_EQP_AREA")
            .addAll(getInJsonData(map,"VIEW_PDA_EQP_AREA"))
            .toResponse<AreaListEntity>()
            .await()

    }

    suspend fun getEqpInfoByArea(map: JsonObject): EqpByAreaListEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/VIEW_PDA_EQP_INFO_BY_AREA")
            .addAll(getInJsonData(map,"VIEW_PDA_EQP_INFO_BY_AREA"))
            .toResponse<EqpByAreaListEntity>()
            .await()

    }

    suspend fun getAllFab(map: JsonObject): AreaListEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/VIEW_PDA_EQP_FAB")
            .addAll(getInJsonData(map,"VIEW_PDA_EQP_FAB"))
            .toResponse<AreaListEntity>()
            .await()

    }

    suspend fun getEqpInfoByFab(map: JsonObject): EqpByAreaListEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/VIEW_PDA_EQPADD_INFO")
            .addAll(getInJsonData(map,"VIEW_PDA_EQPADD_INFO"))
            .toResponse<EqpByAreaListEntity>()
            .await()

    }

    suspend fun getEqpRegister(map: JsonObject): JsonObject {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/TRAN_PDA_EQP_ADD")
            .addAll(getInJsonData(map,"TRAN_PDA_EQP_ADD"))
            .toResponse<JsonObject>()
            .await()

    }

    suspend fun getAllFabLinePosition(map: JsonObject): FabListEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/VIEW_PDA_EQPMOVEIN_INFO")
            .addAll(getInJsonData(map,"VIEW_PDA_EQPMOVEIN_INFO"))
            .toResponse<FabListEntity>()
            .await()

    }

    suspend fun getEqpMoveIn(map: JsonObject): JsonObject {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/TRAN_PDA_EQP_MOVEIN")
            .addAll(getInJsonData(map,"TRAN_PDA_EQP_MOVEIN"))
            .toResponse<JsonObject>()
            .await()

    }

    suspend fun getEqpMoveOut(map: JsonObject): JsonObject {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/TRAN_PDA_EQP_MOVEOUT")
            .addAll(getInJsonData(map,"TRAN_PDA_EQP_MOVEOUT"))
            .toResponse<JsonObject>()
            .await()

    }

    suspend fun updateIP(map: JsonObject): JsonObject {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/TRAN_PDA_EQP_IP")
            .addAll(getInJsonData(map,"TRAN_PDA_EQP_IP"))
            .toResponse<JsonObject>()
            .await()

    }

    suspend fun getRecipeList(map: JsonObject): EqpByAreaListEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/VIEW_PDA_RMSDOWNRECIPET_NAMELIST")
            .addAll(getInJsonData(map,"VIEW_PDA_RMSDOWNRECIPET_NAMELIST"))
            .toResponse<EqpByAreaListEntity>()
            .await()

    }

    suspend fun getRecipeDownLoad(map: JsonObject): Any {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG + "/TRAN_PDA_RMS_DOWNRECIPE")
            .addAll(getInJsonData(map,"TRAN_PDA_RMS_DOWNRECIPE"))
            .toResponse<Any>()
            .await()

    }

}